<%@page import="java.sql.ResultSet"%>
<%@page import="PackDatos.GestionBD"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <!-- Framework CSS -->
        <link rel="stylesheet" href="css/blueprint/screen.css" type="text/css" media="screen, projection">
        <link rel="stylesheet" href="css/blueprint/print.css" type="text/css" media="print">
        <link rel="stylesheet" href="css/blueprint/ie.css" type="text/css" media="screen, projection">
        <!-- Framework CSS -->
        <title></title>
    </head>
    <body>
        <div class=" prepend-5 span-10 append-2 last" style="height:50px;background-color:#FFFFFF"></div>
        <div class=" prepend-5 span-10 append-2 last" style="background-color:#23DBBC;height:20px;"><font color="white"><b>Agregar Curso:</b></font></div>
        <div class=" prepend-5 span-10 append-2 last" style="background-color:#D9DBDA;height:30px;"></div> <!--BDC293-->
        <div class=" prepend-5 span-10 append-2 last" style="background-color:#D9DBDA;height:250px;">
            <form id="form1" method="post" action="">
                <%
                    GestionBD og = new GestionBD();
                    og.conectar();
                    String sql = "select id_matricula from matricula order by id_matricula desc limit 1";
                    ResultSet rs = og.cargadatos(sql);
                    rs.next();
                    int codigo;
                    String codigoMatricula=null;
                    codigo = rs.getInt(1);
                    codigo++;
                    if(codigo>0 && codigo<10){
                        codigoMatricula="M000"+codigo;
                    }else if(codigo>9 && codigo<100){
                        codigoMatricula="M00"+codigo;
                    }else if(codigo>99 && codigo<1000){
                        codigoMatricula="M0"+codigo;
                    }else if(codigo>999 && codigo<10000){
                        codigoMatricula="M"+codigo;
                    }
                %>
                <div class="prepend-1 span-2 append-1" style="background-color:#23DBBC;height:20px;">
                    <font color="white"><b>Codigo:</b></font>
                </div>
                <div class="span-6 last">
                    <input type="text" id="cur_codigo" name="cur_codigo" value="<%out.print(codigoMatricula);%>"/>
                </div>                
                <div class="prepend-1 span-2 append-1" style="background-color:#23DBBC;height:20px;">
                    <font color="white"><b>Curso:</b></font>
                </div>
                <div class="span-6 last">
                    <select id="curso" name="curso">
                        <option value="0">-- Elija su Opcion --</option>
                <c:forEach items="${sessionScope.cursos}" var="lc">
                  <option value="${lc["id_curso"]}">${lc["cur_nombre"]}</option>
                </c:forEach>
                </select>
                </div>
                <div class="prepend-1 span-2 append-1" style="background-color:#23DBBC;height:20px;">
                    <font color="white"><b>Alumno:</b></font>
                </div>
                <div class="span-6 last">
                <select id="alumno" name="alumno">
                    <option value="0">-- Elija su Opcion --</option>
                <c:forEach items="${sessionScope.alumnos}" var="la">
                  <option value="${la["id_alumno"]}">${la["alu_nombre"]} ${la["alu_apellido"]}</option>
                </c:forEach>
                </select>
                </div>
                <div class="prepend-1 span-9 last" style="height:15px;"></div>
                <div class="prepend-3 span-5 append-3 last">
                    <input type="button" id="btnRegistrar" name="btnRegistrar" class="boton" onclick="javascript:matricularAlumno('srv_matricularAlumno','dvprincipal')" value="Registrar">
                </div>
            </form>
            <p>${requestScope.mensaje}</p>
        </div>
    </body>
</html>